package com.choosefine.it.team.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.choosefine.it.base.BaseController;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.common.utils.StringUtils;
import com.choosefine.it.company.model.vo.CompanyInfoListVO;
import com.choosefine.it.company.service.CompanyInfoListService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * 分包承包人获得公司列表
 * 
 * @author 毛俊
 * @date 2016-12-29 
 */
@RestController
@RequestMapping("/managerGetCompanyInfo")
@Api(value = "分包承包人/班组获得公司列表", description = "毛俊")
public class TeamGetCompanyInfoController extends BaseController {
	
	@Autowired
	CompanyInfoListService companyInfoListService;
	
	@ApiImplicitParam(name = "userCode", value = "分包承包人编号", required = true, dataType = "String", paramType = "path")
	@RequestMapping(value = "/getCompanyInfoListByTeamUserCode/{userCode}", method = RequestMethod.GET)
	@ApiOperation(value = "根据分包承包人usercode查找",response=CompanyInfoListVO.class)
	public String getCompanyInfoListByTeamUserCode(@PathVariable String userCode){
		String result = null;
		List<CompanyInfoListVO> list = null;
		if (StringUtils.isNotBlank(userCode)) {
			list = companyInfoListService.getCompanyInfoListByTeamUserCode(userCode);
			if (list != null) {
				result = responseArraySuccess(list, ResultCode.SUCCESS,
						ResultCode.MSG_SUCCESS);
			} else {
				result = responseFail(ResultCode.FAILED,
						ResultCode.MSG_DATA_ISEMPTY);
			}
		} else {
			result = responseFail(ResultCode.MSG_PARAMS_ERROR);
		}
		return result;

	}
}